package kr.co.redcircle.console.dialog.contents;

import kr.co.redcircle.console.dialog.ConsoleDialogContents;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class CertificateDialogContents extends ConsoleDialogContents {

	protected Object result;
	private Text text;
	private Table table;
	private Text text_1;
	
	public CertificateDialogContents(Composite parent, int style) {
		super(parent, style);
	}
	
	public CertificateDialogContents(Composite parent, Integer style, Point dialogSize, Rectangle contentsBound) {
		super(parent, style, dialogSize, contentsBound);
	}

	@Override
	public void createContents(final Shell parent) {
		
		Group grpMediaSelect = new Group(parent, SWT.NONE);
		grpMediaSelect.setText("Media Select");
		grpMediaSelect.setBounds(10, 10, 368, 82);
		
		CLabel lblNewLabel = new CLabel(grpMediaSelect, SWT.NONE);
		lblNewLabel.setImage(SWTResourceManager.getImage(CertificateDialogContents.class, "/kr/co/redcircle/icons/application-certificate.ico"));
		lblNewLabel.setBounds(10, 51, 348, 21);
		lblNewLabel.setText("New Label");
		
		Button btnNewButton = new Button(grpMediaSelect, SWT.NONE);
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				FileDialog fd = new FileDialog(parent, SWT.OPEN);
		        fd.setText("Open");
		        fd.setFilterPath("C:/");
		        String[] filterExt = { "*.txt", "*.doc", ".rtf", "*.*" };
		        fd.setFilterExtensions(filterExt);
		        String selected = fd.open();
		        System.out.println(selected);
			}
		});
		btnNewButton.setBounds(282, 22, 76, 25);
		btnNewButton.setText("Select");
		
		text = new Text(grpMediaSelect, SWT.BORDER | SWT.READ_ONLY);
		text.setBounds(10, 24, 266, 21);
		
		table = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
		table.setBounds(10, 98, 368, 165);
		table.setHeaderVisible(true);
		
		TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn.setWidth(82);
		tblclmnNewColumn.setText("Issued");
		
		TableColumn tblclmnNewColumn_1 = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn_1.setWidth(101);
		tblclmnNewColumn_1.setText("Issuer");
		
		TableColumn tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn_2.setWidth(90);
		tblclmnNewColumn_2.setText("Division");
		
		TableColumn tblclmnNewColumn_3 = new TableColumn(table, SWT.NONE);
		tblclmnNewColumn_3.setWidth(99);
		tblclmnNewColumn_3.setText("Expiration");
		
		TableItem tableItem = new TableItem(table, SWT.NONE);
		tableItem.setText(new String[] {"\uD64D\uAE38\uB3D9", "\uC778\uD53C\uC5B8\uCEE8\uC124\uD305", "\uC0AC\uB0B4\uC778\uC99D\uC6A9", "2013-01-31"});
		tableItem.setImage(SWTResourceManager.getImage(CertificateDialogContents.class, "/kr/co/redcircle/icons/application-certificate.ico"));
		
		CLabel lblNewLabel_1 = new CLabel(parent, SWT.NONE);
		lblNewLabel_1.setImage(SWTResourceManager.getImage(CertificateDialogContents.class, "/kr/co/redcircle/icons/dialog-password.ico"));
		lblNewLabel_1.setBounds(10, 269, 134, 21);
		lblNewLabel_1.setText("certificate password");
		
		text_1 = new Text(parent, SWT.BORDER);
		text_1.setBounds(150, 269, 228, 21);
		
		Button btnNewButton_1 = new Button(parent, SWT.NONE);
		btnNewButton_1.setBounds(302, 348, 76, 25);
		btnNewButton_1.setText("Cancel");
		
		Button btnNewButton_2 = new Button(parent, SWT.NONE);
		btnNewButton_2.setBounds(220, 348, 76, 25);
		btnNewButton_2.setText("Ok");
		
		CLabel lblNewLabel_2 = new CLabel(parent, SWT.NONE);
		lblNewLabel_2.setImage(SWTResourceManager.getImage(CertificateDialogContents.class, "/kr/co/redcircle/icons/audio-volume-high-2.ico"));
		lblNewLabel_2.setBounds(10, 296, 368, 21);
		lblNewLabel_2.setText("New Label");
		
		ProgressBar progressBar = new ProgressBar(parent, SWT.NONE);
		progressBar.setSelection(50);
		progressBar.setBounds(10, 322, 368, 17);
	}

	@Override
	public void setupMessageContents() {

	}
	
}
